package ua.org.nuos.sdms.clientgui.client.components.factory;

import com.vaadin.ui.*;

/**
 * Created by IntelliJ IDEA.
 * User: dio
 * Date: 26.02.12
 * Time: 17:20
 * To change this template use File | Settings | File Templates.
 */
public class LayoutFactory {

    public static HorizontalLayout getMarginHLayout(Component component) {
        HorizontalLayout marginLayout = new HorizontalLayout();
        marginLayout.setSizeFull();
        marginLayout.setMargin(true);
        marginLayout.addStyleName("5px_margin");
        marginLayout.addComponent(component);
        return marginLayout;
    }

    public static VerticalLayout getMarginVLayout(Component component) {
        VerticalLayout marginLayout = new VerticalLayout();
        marginLayout.setSizeFull();
        marginLayout.setMargin(true);
        marginLayout.addStyleName("5px_margin");
        marginLayout.addComponent(component);
        return marginLayout;
    }

    public static VerticalLayout getVLayout(Component... buttons) {
        VerticalLayout layout = new VerticalLayout();
        for (Component b : buttons) {
            layout.addComponent(b);
            layout.setComponentAlignment(b, Alignment.TOP_RIGHT);
        }
        layout.setSpacing(true);
        return layout;
    }

    public static Layout getHButtonsLayout(HorizontalLayout buttons) {
        HorizontalLayout layout = new HorizontalLayout();
        layout.setWidth("100%");
        layout.addComponent(buttons);
        layout.setComponentAlignment(buttons, Alignment.BOTTOM_RIGHT);
        return layout;
    }

    public static HorizontalLayout getHLayout(Component... buttons) {
        HorizontalLayout layout = new HorizontalLayout();
        for (Component button : buttons) {
            layout.addComponent(button);
        }
        layout.setSpacing(true);
        return layout;
    }

    public static HorizontalLayout getHEmptyLayout(String width) {
        HorizontalLayout layout = new HorizontalLayout();
        layout.setWidth(width);
        return layout;
    }

    public static VerticalLayout getVEmptyLayout(String height) {
        VerticalLayout layout = new VerticalLayout();
        layout.setHeight(height);
        return layout;
    }

}
